{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fancy-chain",
   "metadata": {},
   "outputs": [],
   "source": [
    "from code.quoteapi import futuquote\n",
    "import imp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "alone-oasis",
   "metadata": {},
   "outputs": [],
   "source": [
    "#imp.load_module(quote)\n",
    "#imp.reload(futuquote)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "educational-cornwall",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-02-27 16:28:04,635 [open_context_base.py] _socket_reconnect_and_wait_ready:255: Start connecting: host=127.0.0.1; port=11111;\n",
      "2021-02-27 16:28:04,638 [open_context_base.py] on_connected:344: Connected : conn_id=1; \n",
      "2021-02-27 16:28:04,643 [open_context_base.py] _handle_init_connect:445: InitConnect ok: conn_id=1; info={'server_version': 500, 'login_user_id': 716900, 'conn_id': 6771345130589349759, 'conn_key': '090F3084D492CC5F', 'conn_iv': 'D9F0BBF108F035D1', 'keep_alive_interval': 10, 'is_encrypt': False};\n"
     ]
    }
   ],
   "source": [
    "hq = futuquote()\n",
    "query = hq.init_context()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "combined-cream",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "None\n"
     ]
    }
   ],
   "source": [
    "print(query)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "robust-tradition",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(0, {'market_sz': 'CLOSED', 'market_us': 'AFTER_HOURS_END', 'market_sh': 'CLOSED', 'market_hk': 'CLOSED', 'market_hkfuture': 'NIGHT_END', 'market_usfuture': 'FUTURE_CLOSE', 'server_ver': '500', 'trd_logined': True, 'timestamp': '1614414486', 'qot_logined': True, 'local_timestamp': 1614414486.915225, 'program_status_type': 'READY', 'program_status_desc': ''})\n"
     ]
    }
   ],
   "source": [
    "gs = hq.get_global_state()\n",
    "print(gs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "pediatric-internship",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'futuquote' object has no attribute 'context'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-5-41748a12d46e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mhq\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcontext\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_global_state\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m: 'futuquote' object has no attribute 'context'"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "invalid-palace",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'module' object is not callable",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-13-a97e58c6ac6e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mquote\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minit_context\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: 'module' object is not callable"
     ]
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "specific-vitamin",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "dimensional-environment",
   "metadata": {},
   "outputs": [],
   "source": [
    "hq.closecontext()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "rising-jackson",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ready-spice",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "physical-kitty",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
